Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prometheus label "raft_cluster" to non-QQ raft metrics (backport #12148) #12216

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Sep 4, 2024

Adds a <<"raft_cluster">> tag for ra_metrics emitted the stream coordinator and Khepri. By default Ra sets the cluster name as the metrics_key (if not set in config, like it is for QQs). The prometheus plugin ignores atoms that aren't protocol names when rendering labels so these cluster name values disappear. We can convert them into a map #{<<"raft_cluster">> => atom_to_binary(ClusterName, utf8)} to render properly.

Before:

$ curl -s "localhost:15692/metrics/detailed?family=ra_metrics" | grep rabbitmq_raft_term_total
# TYPE rabbitmq_raft_term_total counter
# HELP rabbitmq_raft_term_total Current Raft term number
rabbitmq_raft_term_total{vhost="/",queue="qq"} 9
rabbitmq_raft_term_total 10

After:

$ curl -s "localhost:15692/metrics/detailed?family=ra_metrics" | grep rabbitmq_raft_term_total
# TYPE rabbitmq_raft_term_total counter
# HELP rabbitmq_raft_term_total Current Raft term number
rabbitmq_raft_term_total{vhost="/",queue="qq"} 9
rabbitmq_raft_term_total{raft_cluster="rabbitmq_metadata"} 10

Connects #9665
Connects #12142


This is an automatic backport of pull request #12148 done by Mergify.

By default Ra will use the cluster name as the metrics key. Currently
atom values are ignored by the prometheus plugin's tag rendering
functions, so if you have a QQ and Khepri running and request the
`/metrics/per-object` or `/metrics/detailed` endpoints you'll see values
that don't have labels set for the `ra_metrics` metrics:

    # TYPE rabbitmq_raft_term_total counter
    # HELP rabbitmq_raft_term_total Current Raft term number
    rabbitmq_raft_term_total{vhost="/",queue="qq"} 9
    rabbitmq_raft_term_total 10

With this change we map the name of the Ra cluster to a "raft_cluster"
tag, so instead an example metric might be:

    # TYPE rabbitmq_raft_term_total counter
    # HELP rabbitmq_raft_term_total Current Raft term number
    rabbitmq_raft_term_total{vhost="/",queue="qq"} 9
    rabbitmq_raft_term_total{raft_cluster="rabbitmq_metadata"} 10

This affects metrics for Khepri and the stream coordinator.

(cherry picked from commit 512f883)
@the-mikedavis the-mikedavis changed the title Add prometheus tag "raft_cluster" to non-QQ raft metrics (backport #12148) Add prometheus label "raft_cluster" to non-QQ raft metrics (backport #12148) Sep 4, 2024
@the-mikedavis the-mikedavis merged commit d736254 into v4.0.x Sep 4, 2024
197 checks passed
@the-mikedavis the-mikedavis deleted the mergify/bp/v4.0.x/pr-12148 branch September 4, 2024 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant